package com.hyh.admin.config.websocket;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 群聊服务端
 * @author hyh
 */
@Component
@ServerEndpoint("/groupChat/{ids}")
public class WebSocketGroupServe implements InitializingBean {

    /**  记录当前在线的连接*/
    public static final Map<String, Set<Session>> groupSessionMap = new ConcurrentHashMap<>();
    private static final Logger log = LoggerFactory.getLogger(WebSocketGroupServe.class);

    @Override
    public void afterPropertiesSet() throws Exception {
        log.info("群聊服务端初始化完成");
    }
}
